package com.example.gmwang.washapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by gmwang on 2017/11/15.
 */

public class SplashActivity extends Activity {
    Timer timer;
    Message message;
    private Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 1:
                    if (timer != null) {
                        timer.cancel();
                        timer = null;
                    }
                    Intent i = new Intent(SplashActivity.this,WashViewActivity.class);
                    startActivity(i);
                    break;
                default:
                    break;
            }
        }
    };

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_spalsh);
        timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                message = new Message();
                message.what = 1;
                handler.sendMessage(message);
            }
        }, 3000, 3000);
    }
}
